import request from "@/sheep/request";

export default {
  getMiniImg: (params) =>
    request({
      url: "/h5/member/wechat/code",
      method: "GET",
      params,
    }),
  profile: () =>
    request({
      url: "/h5/member/info",
      method: "GET",
      custom: {
        showLoading: false,
        auth: true,
      },
    }),

  // 账号登录
  accountLogin: (params) =>
    request({
      url: "/h5/account/login",
      method: "post",
      data: params,
      custom: {
        showSuccess: true,
        loadingMsg: "登录中",
      },
    }),
  // 短信登录
  smsLogin: (params) =>
    request({
      url: "/h5/sms/login",
      method: "post",
      data: params,
      custom: {
        showSuccess: true,
        loadingMsg: "登录中",
      },
    }),
  // 绑定openid
  getWechatUserAuth: (params) =>
    request({
      url: "/no-auth/wechat/getWechatUserAuth",
      method: "POST",
      data: params,
    }),
  // 设置会员微信信息
  setWechatInfo: (params) =>
    request({
      url: "/h5/member/setWechatInfo",
      method: "POST",
      data: params,
    }),
  // 短信注册
  smsRegister: (data) =>
    request({
      url: "/h5/register",
      method: "POST",
      data,
      custom: {
        showSuccess: true,
        loadingMsg: "正在注册",
      },
    }),
  // 注册校验手机号
  validatePhone: (data) =>
    request({
      url: `/h5/validate/` + data,
      method: "get",
    }),

  recordLogin: () =>
    request({
      url: "/h5/record/login",
      method: "GET",
    }),

  // 添加分享记录
  addShareLog: (data) => {
    request({
      url: "share/add",
      method: "POST",
      data,
      custom: {
        showError: false,
      },
    });
  },
  share: {
    list: (params) =>
      request({
        url: "share/list",
        method: "GET",
        params,
      }),
  },
  address: {
    default: () =>
      request({
        url: "h5/member/address/default",
        method: "GET",
        custom: {
          showError: false,
        },
      }),
    list: () =>
      request({
        url: "h5/member/address/list",
        method: "GET",
        custom: {
          showError: false,
        },
      }),
    create: (data) =>
      request({
        url: "h5/member/address/create",
        method: "POST",
        data,
        custom: {
          showSuccess: true,
        },
      }),
    update: (data) =>
      request({
        url: "h5/member/address/update",
        method: "PUT",
        data,
        custom: {
          showSuccess: true,
        },
      }),
    detail: (id) =>
      request({
        url: "h5/member/address/" + id,
        method: "GET",
      }),
    delete: (id) =>
      request({
        url: "h5/member/address/" + id,
        method: "DELETE",
      }),
  },

  //数量接口
  // data: () =>
  //   request({
  //     url: 'user/user/data',
  //     method: 'GET',
  //     custom: {
  //       showLoading: false,
  //       auth: true,
  //     },
  //   }),
};
